package org.jeecg.modules.system.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.system.entity.AppButton;
import org.jeecg.modules.system.service.IAppButtonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/b/sys/appWebBtn")
@RestController
@Slf4j
@Api(tags="移动端按钮控制")
public class    AppWebButtonController {


    @Autowired
    private IAppButtonService appButtonService;



    @RequestMapping("queryAppButtonList")
    public Result<List<AppButton>> queryAppButtonList(@RequestParam("userId")String userId){
        Result<List<AppButton>> result = new Result<>();
        List<AppButton> appButtons = appButtonService.queryAppButtonList();
        for (AppButton appButton:appButtons ) {
            List<AppButton> sunAppButtonList = appButton.getSunAppButtonList();
            for (AppButton app:sunAppButtonList) {
                if (app.getIdentify().equals("Z107")){
                    Integer bXCount = appButtonService.selectBxCount(userId);
                    app.setCount(bXCount);
                }
                if (app.getIdentify().equals("X105")){
                    Integer tXCount = appButtonService.selectTxCount(userId);
                    app.setCount(tXCount);
                }
                if (app.getIdentify().equals("Z105")){
                    Integer xJCount = appButtonService.selectXjCount(userId);
                    app.setCount(xJCount);
                }
            }
        }
        result.setSuccess(true);
        result.setResult(appButtons);
        return result;
    }

}
